package ge.devfest.hackathon.gg;

import ge.devfest.hackathon.gg.model.DatabaseHelper;
import android.content.Intent;
import android.os.Bundle;

import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.j256.ormlite.android.apptools.OpenHelperManager;

public class BaseActivity extends SherlockFragmentActivity {

	public static final String SAVED_OBJECT_ID = "saved id";
	private DatabaseHelper mHelper;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mHelper = OpenHelperManager.getHelper(this, DatabaseHelper.class);
	}

	public DatabaseHelper getHelper() {
		return mHelper;
	}
	
	public void startActivity(Class<?> cls) {
		startActivity(new Intent(this, cls));
	}
	
	public void startActivity(Class<?> cls, int id) {
		startActivity(new Intent(this, cls).putExtra(SAVED_OBJECT_ID, id));
	}
	
	@Override
	protected void onDestroy() {
		super.onDestroy();
		OpenHelperManager.releaseHelper();
	}
}
